using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using CDIO1.Models;
using System.Data;

namespace CDIO1.Controllers
{
    public class ProfController : Controller
    {
        //
        // GET: /Prof/

        public ActionResult Index()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return RedirectToAction("Index", "Home");
            }
            else
            {
                if (!User.IsInRole("professor"))
                {
                    return RedirectToAction("Index", "Home");
                }
            }
            return View();
        }
        public ActionResult Bloom()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return RedirectToAction("Index", "Home");
            }
            else
            {
                if (!User.IsInRole("professor"))
                {
                    return RedirectToAction("Index", "Home");
                }
            }
            return View();
        }
        public ActionResult Staff()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return RedirectToAction("Index", "Home");
            }
            else
            {
                if (!User.IsInRole("professor"))
                {
                    return RedirectToAction("Index", "Home");
                }
            }
            return View();
        }
        public ActionResult ViewStaffInformation()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return RedirectToAction("Index", "Home");
            }
            else
            {
                if (!User.IsInRole("professor"))
                {
                    return RedirectToAction("Index", "Home");
                }
            }
            return View();
        }



        public ActionResult ManageCourse()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return RedirectToAction("Index", "Home");
            }
            else
            {
                if (!User.IsInRole("professor"))
                {
                    return RedirectToAction("Index", "Home");
                }
            }
            return View();
        }
        public ActionResult ManageSyllabus(string id)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return RedirectToAction("Index", "Home");
            }
            else
            {
                if (!User.IsInRole("professor"))
                {
                    return RedirectToAction("Index", "Home");
                }
            }
            int _id = 0;
            bool check = Int32.TryParse(id, out _id);
            ViewData["scheduleID"] = "-1";
            if (!check) // parameter id is invalid
            {

            }
            else
            {

                var db = new SyllabusDataContext();
                var syll = from p in db.Syllabus where p.CourseID == _id select p;
                if (syll.Count() > 0)
                {
                    foreach (Syllabus s in syll)
                    {
                        ViewData["scheduleID"] = s.TeachingScheduleID;
                        ViewData["syllabusID"] = s.ID;
                    }
                }
            }
            return View();
        }


        public ActionResult EditProfile()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return RedirectToAction("Index", "Home");
            }
            else
            {
                if (!User.IsInRole("professor"))
                {
                    return RedirectToAction("Index", "Home");
                }
            }
            string username = User.Identity.Name;
            ViewData["UserName"] = username;
            return View();
        }

        public ActionResult VerbList()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return RedirectToAction("Index", "Home");
            }
            else
            {
                if (!User.IsInRole("professor"))
                {
                    return RedirectToAction("Index", "Home");
                }
            }
            return View();
        }
        public ActionResult Method()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return RedirectToAction("Index", "Home");
            }
            else
            {
                if (!User.IsInRole("professor"))
                {
                    return RedirectToAction("Index", "Home");
                }
            }
            return View();
        }

        public ActionResult EvalMethodLanguage()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return RedirectToAction("Index", "Home");
            }
            else
            {
                if (!User.IsInRole("professor"))
                {
                    return RedirectToAction("Index", "Home");
                }
            }
            return View();
        }
        public ActionResult Language()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return RedirectToAction("Index", "Home");
            }
            else
            {
                if (!User.IsInRole("professor"))
                {
                    return RedirectToAction("Index", "Home");
                }
            }
            return View();
        }
        public ActionResult TeachMethodLanguage()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return RedirectToAction("Index", "Home");
            }
            else
            {
                if (!User.IsInRole("professor"))
                {
                    return RedirectToAction("Index", "Home");
                }
            }
            return View();
        }
        public ActionResult Standard()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return RedirectToAction("Index", "Home");
            }
            else
            {
                if (!User.IsInRole("professor"))
                {
                    return RedirectToAction("Index", "Home");
                }
            }
            return View();
        }
        public ActionResult StandardLO()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return RedirectToAction("Index", "Home");
            }
            else
            {
                if (!User.IsInRole("professor"))
                {
                    return RedirectToAction("Index", "Home");
                }
            }
            return View();
        }
        public ActionResult Program()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return RedirectToAction("Index", "Home");
            }
            else
            {
                if (!User.IsInRole("professor"))
                {
                    return RedirectToAction("Index", "Home");
                }
            }
            return View();
        }
        public ActionResult ProgramDetail()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return RedirectToAction("Index", "Home");
            }
            else
            {
                if (!User.IsInRole("professor"))
                {
                    return RedirectToAction("Index", "Home");
                }
            }
            return View();
        }
        public ActionResult Major()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return RedirectToAction("Index", "Home");
            }
            else
            {
                if (!User.IsInRole("professor"))
                {
                    return RedirectToAction("Index", "Home");
                }
            }
            return View();
        }
        public ActionResult CourseOfMajor()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return RedirectToAction("Index", "Home");
            }
            else
            {
                if (!User.IsInRole("professor"))
                {
                    return RedirectToAction("Index", "Home");
                }
            }
            return View();
        }
    }
}
